package reflect;

import reflect.annotations.AutoRunClass;
import reflect.annotations.AutoRunMethod;

import java.lang.reflect.Method;

/**
 * 访问注解参数
 */
public class ReflectDemo10 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        if(cls.isAnnotationPresent(AutoRunClass.class)){
            Method method = cls.getDeclaredMethod("watchTV");
            if(method.isAnnotationPresent(AutoRunMethod.class)){
                AutoRunMethod arm = method.getAnnotation(AutoRunMethod.class);
                int value = arm.value();
                System.out.println("参数值:"+value);
            }
        }
    }
}
